<template>
  <div class="viewcontainer" v-if="dataset">
    <el-row class="view-header">
      <el-col :span="22">
        <hi-lquery v-bind="queryPanel" :target="dataset"></hi-lquery>
      </el-col>
      <el-col :span="2" style="text-align: right">
        <el-button type="primary" @click="showAdd">新增</el-button>
      </el-col>
    </el-row>
    <el-row class="view-main">
      <el-table
        ref="dataTable"
        :data="dataset.data"
        height="100%"
        style="width: 100%"
        v-loading="dataset.loading"
      >
        <el-table-column type="index" width="50" />
        <el-table-column prop="FNUMBER" label="单号" width="160" />
        <el-table-column prop="FINCOMETYPE" label="收入类型" width="180" />
        <el-table-column prop="FMONEY" label="收入金额" width="140">
        </el-table-column>
        <el-table-column prop="FNOTE" label="备注">
          <template slot-scope="scope">
            <div class="text-truncate" :title="scope.row.FNOTE">
              {{ scope.row.FNOTE }}
            </div>
          </template>
        </el-table-column>
        <el-table-column prop="FUSERID" label="创建人" width="100" />
        <el-table-column prop="FCREATEDATE" label="创建时间" width="160" />
        <el-table-column prop="FAUDIT" label="审核" width="80">
          <template slot-scope="scope">
            <audittag v-model="scope.row.FAUDIT"></audittag>
          </template>
        </el-table-column>
        <el-table-column fixed="right" label="操作" width="100">
          <template slot-scope="scope">
            <el-button
              type="text"
              v-if="scope.row.FAUDIT != 0"
              title="编辑"
              size="small"
              @click="showEdit(scope.row, scope.row.FAUDIT)"
            >
              <i class="el-icon-edit"></i>
            </el-button>
            <el-button
              type="text"
              v-if="scope.row.FAUDIT == 0"
              title="详情"
              size="small"
              @click="showEdit(scope.row, scope.row.FAUDIT)"
            >
              <i class="el-icon-tickets"></i>
            </el-button>
            <el-button
              type="text"
              :disabled="scope.row.FAUDIT == 0"
              title="删除"
              size="small"
              @click="remove(scope.row)"
            >
              <i class="el-icon-delete"></i>
            </el-button>
          </template>
        </el-table-column>
      </el-table>
    </el-row>
    <el-row class="view-footer pagebar">
      <hi-pagination
        background
        :total="dataset.total"
        :target="dataset"
      ></hi-pagination>
    </el-row>
  </div>
</template>

<script>
import { HiPagination, HiLquery, dataHelper } from "hi-ui";
import viewBase from "../../base";
import expenditureCfg from "./dataset";
import audittag from "@/views/component/audittag";
export default {
  name: "withdrawlist",
  extends: viewBase,
  components: {
    HiPagination,
    HiLquery,
    audittag,
  },
  data() {
    let datasetCfg = Object.assign({}, expenditureCfg, {
      action: "autoAction",
    });
    return {
      //数据桥梁
      dataBridge: new Map(),
      dataset: null,
      //数据集配置
      datasetCfg: datasetCfg,
      total: 100,
      //查询面板配置
      queryPanel: {
        columnsTotal: 2,
        fields: [
          {
            element: "el-input",
            label: "单号",
            name: "FNUMBER",
          },
         
        ],
      },
    };
  },
  model: {
    prop: "value",
    event: "valuechange",
  },
  props: {
    value: {
      type: Object,
    },
  },

  computed: {},
  watch: {},
  methods: {
    showAdd() {
      this.openByPath("/finance/income/detail", null, {
        title: "新增收入",
      });
    },
    showEdit(data, detail) {
      this.openByPath(
        "/finance/income/detail",
        {
          id: data.FID,
        },
        {
          title: "【" + data.FNUMBER + (detail == 0 ? "】详情" : "】编辑"),
          target: "_blank",
        }
      );
    },
    remove(data) {
      this.$confirm("确定要删除【" + data.FNUMBER + "】", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(() => {
          let saveHelper = this.createSaveHelper(this.dataset.modelFile);
          saveHelper.remove(data);
          saveHelper.save().then((res) => {
            this.dataset.reload();
            this.$message({
              type: "success",
              message: "删除成功!",
            });
          });
        })
        .catch(() => {});
    },
  },
  mounted() {
    this.dataset = this.createDataSet(this.datasetCfg);
    this.dataBridge.set(this.dataset, ["dataTable"]);
  },
};
</script>

<style rel="stylesheet/scss" lang="scss" scope>
</style>
